#!/usr/bin/env escript
%% -*- erlang -*-
%%! -smp enable -sname compile_test_contract -mnesia debug verbose

main([TestName, EbinDir]) ->
    code:add_patha(lists:concat([EbinDir, "/aesophia/ebin/"])),
    code:add_patha(lists:concat([EbinDir, "/aebytecode/ebin/"])),
    TestDir = "../test/contracts/",
    case file:read_file(lists:concat([TestDir,
                                      TestName, ".aes"])) of
        {ok, Bin} ->
            C = binary_to_list(Bin),
            io:format("Compiling contract ~s~s.aes\n\n", [TestDir, TestName]),
            aeso_compiler:from_string(C, []);
        {error, enoent} ->
            io:format("Contract ~s.aes not found in ~s\n", [TestName, TestDir]),
            halt(127)
    end.

